// Created from GroupGenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class FACILITY_DETAIL_SUR_P09 : AbstractGroup
    {
        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("10 FAC",10)]
  	    [HL7Field(HL7Version.v23, 10, HL7Repeat.False, HL7Required.True,"FAC")]
	    public FAC FAC {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("11 PDC",11)]
  	    [HL7Field(HL7Version.v23, 11, HL7Repeat.False, HL7Required.True,"PDC")]
	    public PDC PDC {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("12 NTE",12)]
  	    [HL7Field(HL7Version.v23, 12, HL7Repeat.False, HL7Required.True,"NTE")]
	    public NTE NTE {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override void ConsumeTextSegmentsForGroup(Stack<string> availableData, HL7ParserOptions options) {

			FAC = PopSegmentParseAndCheckRequired<FAC>(availableData, options, "FAC");
			PDC = PopSegmentParseAndCheckRequired<PDC>(availableData, options, "PDC");
			NTE = PopSegmentParseAndCheckRequired<NTE>(availableData, options, "NTE");
        }

		internal override bool CanConsume(string availableData, HL7ParserOptions options)
        {
			bool isFAC = availableData.StartsWith("FAC", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("FAC", options.Version) || isFAC) {
				return isFAC;
			}
			bool isPDC = availableData.StartsWith("PDC", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("PDC", options.Version) || isPDC) {
				return isPDC;
			}
			bool isNTE = availableData.StartsWith("NTE", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("NTE", options.Version) || isNTE) {
				return isNTE;
			}
			return false;
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "FACILITY_DETAIL";
			}
        }

        static FACILITY_DETAIL_SUR_P09() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(FACILITY_DETAIL_SUR_P09));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
		 if (FAC != null) {
			string segmentValue = FAC.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (PDC != null) {
			string segmentValue = PDC.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (NTE != null) {
			string segmentValue = NTE.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
           return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }
    }
}

